#!/usr/bin/env python
# -*- coding: utf-8 -*-
# datetime: 1/7/2024 下午10:43
# Author: name
# File: __init__.py.py
# ide: PyCharm
# description:
import datetime
import time

from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates

app = FastAPI()

# 挂载静态文件目录
app.mount("/static", StaticFiles(directory="static"), name="static")
# 设置模板目录
templates = Jinja2Templates(directory="templates")


# 示例数据，一个包含多个项目的列表
sample_data = [
    {"id": 1, "name": "Project A"},
    {"id": 2, "name": "Project B"},
    {"id": 3, "name": "Project C"}
]

@app.get("/")
async def read_root(request: Request):
    current_time = time.strftime("%Y-%m-%d %H:%M:%S")

    # 示例数据，可以根据需要修改
    test_overview = "Some test overview information"
    test_environment = "Test environment details"
    test_suites = ["Suite A", "Suite B", "Suite C"]
    test_steps = ["Step 1", "Step 2", "Step 3"]
    response_list=[{"suite_name": "场景名称_不改的人是csa", "suite_desc": "场景描述信息_不改的人是piga", "variables": ["局部变量username的值huhaohao保存成功", "局部变量password的值123456保存成功", "局部变量code的值185保存成功", "局部变量code1的值220196_shre保存成功"], "test_steps": [{"step_name": "_basic_taskInstance_mytaskPagerV2csa", "step_desc": "c", "wait_time": 0, "set_up": ["函数get_str('2dcsxd')的值d已保存为局部变量my_name"], "tear_down": ["函数get_str('erwewfds')的值e已保存为局部变量password1"], "request": {"path": "/basic/taskInstance/mytaskPagerV2", "method": "get", "headers": {"Accept": "*/*", "Accept-Language": "zh-CN,zh;q=0.9", "Cache-Control": "no-cache", "Connection": "keep-alive", "Pragma": "no-cache", "Referer": "http://bitsun-uat.cc0b9108c833e4298b9db565441546718.cn-shanghai.alicontainer.com/$/main-project-front/", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"}, "data": None, "params": {"currentPage": "1", "pageSize": "5", "qp-status-in": "0,1,2"}, "files": {}}, "sql_data": [], "downloads": [], "extract": ["接口响应中status的值0已保存为局部变量status", "接口响应中msg的值Success已保存为局部变量msg", "接口响应中data.totalCount的值0已保存为局部变量totalCount"], "checker": {"check_result": "断言失败", "code": 200, "json": ["status==`0`断言失败,实际值为0,类型为str", "data.totalCount==`1613`断言失败,实际值为0,类型为str", "data.pageSize==`5`断言失败,实际值为5,类型为str"], "re": [], "contains": ["字符串totalCount在响应中", "字符串totalPage在响应中"]}, "response": "{\"status\":\"0\",\"msg\":\"Success\",\"traceId\":\"bd7a32bd555d450f966b8312cda3dcc6\",\"data\":{\"totalCount\":\"0\",\"pageSize\":\"5\",\"totalPage\":\"0\",\"currentPage\":\"1\",\"list\":[],\"orderItems\":[],\"searchCount\":true}}"}]}]


    return templates.TemplateResponse("index.html", {
        "request": request,
        "current_time": current_time,
        "test_overview": test_overview,
        "test_environment": test_environment,
        "test_suites": test_suites,
        "test_steps": test_steps,
        "response_list":response_list
    })